#!/bin/bash
#
# rml_move
#    move Roland Modela
#
# Neil Gershenfeld
# CBA MIT 9/18/10
#
# (c) Massachusetts Institute of Technology 2010
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#

#
# Modified by Blair Evans 2/17/2011 for MDX-40A mill
# changed from serial to printer device and 100 steps per mm instead of 40
#

#
# check command line
#

if [ $# -eq 0 ] || [ $# -gt 3 ]; then
   echo command line: rml_move x y [port]
   echo "   x,y, = position to move to (mm)"
   echo "   printer = rml printer name (optional, default Roland-MDX-40A)"
   exit
   fi

#
# get command line arguments
#
if [ $# -eq 2 ]
   then
      printer="Roland-MDX-40A"
   else
      printer=$3
   fi

#
# move
#

x=$(echo "(100.0*$1)/1" | bc) # 100/mm changed from 40 -bhe
y=$(echo "(100.0*$2)/1" | bc) # 100/mm changed from 40 -bhe

cmd="echo 'PA;PA;!VZ10;!PZ0,100;PU $x $y;PD $x $y;!MC0;' | lpr -P$printer; lpq -P$printer"
echo $cmd
eval $cmd


